<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList">
        <template slot="menuLeft">
           <el-popover
            v-if="permissions.stm_swstcycleapply_audit"
            placement="bottom"
            width="260"
            v-model="batchReviewVisible"
          >
            <div style="text-align: center; margin: 0">
              <el-form>
                <el-form-item label="异常通知内容">
                  <el-input type="textarea" span="24" v-model="diffCase"></el-input>
                </el-form-item>
              </el-form>
              <el-button size="mini" type="primary" @click="MyConfirm()">通知</el-button>
              <el-button type="primary" size="mini" @click="batchReviewVisible=false">取消</el-button>
            </div>
            <el-button type="primary" size="small" :hidden="true" v-if="false" slot="reference">通知</el-button>
          </el-popover>          
	  <el-button type="primary"  v-if="permissionList.delBtn"  size="small"  @click="handleDelete()">高级删除</el-button>          
	  <el-button type="primary" size="small" @click="handleExport">导出</el-button>
          <el-button type="primary" size="small" :hidden="true" v-if="false" @click="handlePrint">打印</el-button>
        </template>	
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
  import baseCrud from '@/mixins/base-crud'
  import { confirmObj ,delBatch} from '@/api/subway/swststockaudit'
  import { nowDate } from "@/const/crud/subway/swststockaudit";
  export default {
    name: 'swststockaudit',
    mixins: [baseCrud('subway/swststockaudit')],
    data() {
      return {
        batchReviewVisible:false,
        diffCase:'',
        searchForm: {
          statisticsDate: nowDate
        }
      }
    },
    computed: {
      permissionList() {
        return {
          addBtn: this.vaildData(this.permissions.swststock_add, false),
          delBtn: this.vaildData(this.permissions.swststock_superdel, false),
          editBtn: this.vaildData(this.permissions.swststock_edit, false)
        };
      }
    },
    methods: {
      //删除多条数据
       //高级删除操作
     handleDelete: function () {
        if (this.$refs.crud.tableSelect.length < 1) {
          this.$message.error("请选择数据！");
          return false;
        }
        let ids = [];
        for (const table of this.$refs.crud.tableSelect) {         
          ids.push(table.id);
        }
        this.$confirm("确认删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          delBatch(ids)
            .then((data) => {
              this.$message.success("删除成功");
              this.getList(this.page);
              done();
            })
            .catch(() => {
              loading();
            });
        });
      },
     
      MyConfirm(){
        if (this.$refs.crud.tableSelect.length < 1) {
          this.$message.error("请选择数据");
          return false;
        }
        let ids = [];
        for (const table of this.$refs.crud.tableSelect) {
          table.diffCase=this.diffCase;
          ids.push(table)
        }
        confirmObj(ids).then(data => {
          this.$message.success('通知成功');
          this.batchReviewVisible=false;
          this.getList(this.page);
        })
      }
    }
  }
</script>
